/*
 * @Author: cz
 * @Date: 2019-05-13 10:51
 * @Last Modified by:
 * @Last Modified time: 2019-05-13 10:51
 * @Description: 课题相关
 */

import request from '@/router/axios'
import {subjectUrls,opinionUrls} from '@/const/apiUrl'

/**
 * 课题列表查询
 * @param {*} query
 */
export function getSubjectList (query) {
  return request({
    url: subjectUrls.getSubjectList,
    method: 'get',
    params:query
  })
}


/**
 * 课题列表查询
 * @param {*} query
 */
export function getSubjectTreeList (query) {
  return request({
    url: subjectUrls.getSubjectTreeList,
    method: 'get',
    params:query
  })
}

/**
 * 课题列表查询
 * @param {*} query
 */
export function getSubjectTreeDeptList (query) {
  return request({
    url: subjectUrls.getSubjectTreeDeptList,
    method: 'get',
    params:query
  })
}

/**
 * 课题列表查询
 * @param {*} query
 */
export function getSubjectResultList (query) {
  return request({
    url: subjectUrls.getSubjectResultList,
    method: 'get',
    params:query,
  })
}


/**
 * 课题列表查询
 * @param {*} query
 */
export function getSubjectDeptList (query) {
  return request({
    url: subjectUrls.getSubjectDeptList,
    method: 'get',
    params:query,
  })
}

/**
 * 课题征集多个反馈意见列表查询
 * @param {*} query
 */
export function getSubjectOpinBackList (query) {
  return request({
    url: subjectUrls.getSubjectOpinBackList,
    method: 'get',
    params:query,
  })
}

/**
 * 课题列表查询
 * @param {*} query
 */
export function addSubject (query) {
  return request({
    url: subjectUrls.addSubject,
    method: 'post',
    data: query
  })
}

/**
 * 课题列表查询
 * @param {*} query
 */
export function editSubject (id,query) {
  return request({
    url: subjectUrls.editSubject+id,
    method: 'put',
    data: query
  })
}

/**
 * 课题征集反馈结束接口
 * @param {*} query
 */
export function subjectOpinionBackFinish (id) {
  return request({
    url: subjectUrls.subjectOpinionBackFinish+id,
    method: 'put',
  })
}


/**
 * 课题列表查询
 * @param {*} query
 */
export function changeSubjectState (id,query) {
  return request({
    url: subjectUrls.changeSubjectState+id,
    method: 'put',
    data: query
  })
}
/**
 * 课题列表查询
 * @param {*} query
 */
export function releaseSubject (id,query) {
  return request({
    url: subjectUrls.releaseSubject+id,
    method: 'put',
    data: query
  })
}

/**
 * 课题列表查询
 * @param {*} query
 */
export function subjectLevy (query) {
  return request({
    url: subjectUrls.subjectLevy,
    method: 'post',
    data: query
  })
}

/**
 * 添加课题成果
 * @param {*} query
 */
export function addSubjectResult (query) {
  return request({
    url: subjectUrls.addSubjectResult,
    method: 'post',
    data: query
  })
}

/**
 * 修改课题成果
 * @param {*} query
 */
export function editSubjectResult (id,data) {
  return request({
    url: subjectUrls.editSubjectResult+id,
    method: 'put',
    data: data
  })
}

/**
 * 课题列表查询
 * @param {*} query
 */
export function rejectLevyFeedback (query) {
  return request({
    url: subjectUrls.rejectLevyFeedback,
    method: 'post',
    data: query
  })
}

/**
 * 课题列表查询
 * @param {*} query
 */
export function disagreeLevyFeedback (query) {
  return request({
    url: subjectUrls.disagreeLevyFeedback,
    method: 'post',
    data: query
  })
}

/**
 * 课题列表查询
 * @param {*} query
 */
export function getLevyResultList (query) {
  return request({
    url: subjectUrls.getLevyResultList,
    method: 'get',
    params: query
  })
}

export function subjectTrack (query) {
  return request({
    url: subjectUrls.subjectTrack,
    method: 'get',
    params: query
  })
}

/**
 * 课题列表查询
 * @param {*} query
 */
export function getPlanSubjectList (query) {
  return request({
    url: subjectUrls.getPlanSubjectList,
    method: 'get',
    params: query
  })
}

/**
 * 课题列表查询
 * @param {*} query
 */
export function getDeptIds (query) {
  return request({
    url: subjectUrls.getDeptIds,
    method: 'get',
    params: query
  })
}

/**
 * 课题列表查询
 * @param {*} query
 */
export function getSubjectInfo (subjectId) {
  return request({
    url: subjectUrls.getSubjectInfo+subjectId,
    method: 'get',
  })
}

/**
 * 课题列表查询
 * @param {*} query
 */
export function getDutyDept (query) {
  return request({
    url: subjectUrls.getDutyDept,
    method: 'get',
    params:query,
  })
}

/**
 * 课题列表查询
 * @param {*} query
 */
export function addDutyDept (query) {
  return request({
    url: subjectUrls.addDutyDept,
    method: 'post',
    params:query,
  })
}

/**
 * 课题列表查询
 * @param {*} query
 */
export function levyDetail (collectionId) {
  return request({
    url: subjectUrls.levyDetail+collectionId,
    method: 'get',
  })
}

/**
 * 课题列表查询
 * @param {*} query
 */
export function subjectOpinionDetail (id) {
  return request({
    url: subjectUrls.subjectOpinionDetail+id,
    method: 'get',
  })
}

/**
 * 课题列表查询
 * @param {*} query
 */
export function subjectReportOpnDetail (id) {
  return request({
    url: subjectUrls.subjectReportOpnDetail+id,
    method: 'get',
  })
}

/**
 * 课题列表查询
 * @param {*} query
 */
export function levyDelete (collectionId) {
  return request({
    url: subjectUrls.levyDelete+collectionId,
    method: 'delete',
  })
}

/**
 * 新增课题征求意见
 * @param {*} query
 */
export function addSubjectOPinion (query) {
  return request({
    url: subjectUrls.addSubjectOPinion,
    method: 'post',
    data:query,
  })
}

/**
 * 新增课题征求意见
 * @param {*} query
 */
export function addSubjectReportOpn (query) {
  return request({
    url: subjectUrls.addSubjectReportOpn,
    method: 'post',
    data:query,
  })
}
/**
 * 新增课题征求意见
 * @param {*} query
 */
export function addSubjectReport (query) {
  return request({
    url: subjectUrls.addSubjectReport,
    method: 'post',
    data:query,
  })
}

/**
 * 分页查询课题意见征集
 * @param {*} query
 */
export function getSubjectOpinionList (query) {
  return request({
    url: subjectUrls.getSubjectOpinionList,
    method: 'get',
    params:query,
  })
}

/**
 * 分页查询课题意见征集
 * @param {*} query
 */
export function getLevyFeedbackAllList (query) {
  return request({
    url: subjectUrls.getLevyFeedbackAllList,
    method: 'get',
    params:query,
  })
}

/**
 * 分页查询课题意见征集
 * @param {*} query
 */
export function getLevyFeedbackSingleList (query) {
  return request({
    url: subjectUrls.getLevyFeedbackSingleList,
    method: 'get',
    params:query,
  })
}

/**
 * 分页查询课题意见征集
 * @param {*} query
 */
export function getCollectionFiles (query) {
  return request({
    url: subjectUrls.getCollectionFiles,
    method: 'get',
    params:query,
  })
}

/**
 * 分页查询课题意见征集
 * @param {*} query
 */
export function getSubjectReportHistoryList (query) {
  return request({
    url: subjectUrls.getSubjectReportHistoryList,
    method: 'get',
    params:query,
  })
}

/**
 * 分页查询课题意见征集
 * @param {*} query
 */
export function getTargetformContent (id) {
  return request({
    url: subjectUrls.getTargetformContent+id,
    method: 'get',
  })
}
/**
 * 分页查询课题意见征集
 * @param {*} query
 */
export function getsubjectReportOpnList (query) {
  return request({
    url: subjectUrls.getsubjectReportOpnList,
    method: 'get',
    params:query,
  })
}


/**
 * 分页查询课题意见征集
 * @param {*} query
 */
export function getCollectionFileList (query) {
  return request({
    url: subjectUrls.getCollectionFileList,
    method: 'get',
    params:query,
  })
}


/**
 * 分页查询课题意见征集
 * @param {*} query
 */
export function getmaterialCollectionSingle () {
  return request({
    url: subjectUrls.getmaterialCollectionSingle,
    method: 'get',
  })
}


/**
 * 分页查询课题意见征集
 * @param {*} query
 */
export function subjectOpinionDelete (id) {
  return request({
    url: subjectUrls.subjectOpinionDelete+id,
    method: 'delete',
  })
}

/**
 * 分页查询课题意见征集
 * @param {*} query
 */
export function subjectReportOpnDelete (id) {
  return request({
    url: subjectUrls.subjectReportOpnDelete+id,
    method: 'delete',
  })
}

/**
 * 分页查询课题意见征集
 * @param {*} query
 */
export function subjectHistoryDelete (id) {
  return request({
    url: subjectUrls.subjectHistoryDelete+id,
    method: 'delete',
  })
}

/**
 * 分页查询课题意见征集
 * @param {*} query
 */
export function inclusionPlan (id) {
  return request({
    url: subjectUrls.inclusionPlan+id,
    method: 'put',
  })
}


/**
 * 分页查询课题意见征集
 * @param {*} query
 */
export function commitFormcontent (query) {
  return request({
    url: subjectUrls.commitFormcontent+query.targetId,
    method: 'put',
    data:query
  })
}


/**
 * 课题列表查询
 * @param {*} query
 */
export function draftSubjectPlan (query) {
  return request({
    url: subjectUrls.draftSubjectPlan,
    method: 'post',
    data: query
  })
}

/**
 * 课题列表查询
 * @param {*} query
 */
export function addCollectionFile (query) {
  return request({
    url: subjectUrls.addCollectionFile,
    method: 'post',
    data: query
  })
}

/**
 * 删除材料收集
 * @param {*} query
 */
export function deleteCollectionFile (query) {
  return request({
    url: subjectUrls.deleteCollectionFile,
    method: 'delete',
    data: query
  })
}


/**
 * 课题列表查询
 * @param {*} query
 */
export function subjectAddDept (query) {
  return request({
    url: subjectUrls.subjectAddDept,
    method: 'post',
    data: query
  })
}

/**
 * 课题列表查询
 * @param {*} query
 */
export function submitEndSubject (query) {
  return request({
    url: subjectUrls.submitEndSubject,
    method: 'post',
    data: query
  })
}

/**
 * 课题列表查询
 * @param {*} query
 */
export function addSubjectPlan (query) {
  return request({
    url: subjectUrls.addSubjectPlan,
    method: 'post',
    data: query
  })
}

/**
 * 课题列表查询
 * @param {*} query
 */
export function addSubjectPlanOpinion (query) {
  return request({
    url: opinionUrls.addSubjectPlanOpinion,
    method: 'post',
    data: query
  })
}

/**
 * 课题列表查询
 * @param {*} query
 */
export function subjectCollection (query) {
  return request({
    url: opinionUrls.subjectCollection,
    method: 'post',
    data: query
  })
}


/**
 * 课题列表查询
 * @param {*} query
 */
export function subjectEditDept (query) {
  return request({
    url: subjectUrls.subjectEditDept,
    method: 'put',
    data: query
  })
}

/**
 * 课题列表查询
 * @param {*} query
 */
export function releasePlan (planId) {
  var url = subjectUrls.releasePlan.replace("{planId}",planId);
  return request({
    url: url,
    method: 'put',
  })
}

/**
 * 分页查询课题意见征集
 * @param {*} query
 */
export function exportSubjectAssignDept (planId) {
  var url = subjectUrls.exportSubjectAssignDept.replace("{planId}",planId);
  return request({
    url: url,
    method: 'get',
    responseType: 'blob'
  })
}



/**
 * 课题列表查询
 * @param {*} query
 */
export function editSubjectPlan (query) {
  return request({
    url: subjectUrls.editSubjectPlan+query.planId,
    method: 'put',
    data: query.subjectForm
  })
}

/**
 * 课题列表查询
 * @param {*} query
 */
export function endSubjectAgree (query) {
  return request({
    url: subjectUrls.endSubjectAgree+query.applyId,
    method: 'put',
    data: query.endSubjectForm
  })
}

/**
 * 课题列表查询
 * @param {*} query
 */
export function endSubjectDisagree (query) {
  return request({
    url: subjectUrls.endSubjectDisagree+query.applyId,
    method: 'put',
    data: query.endSubjectForm
  })
}

/**
 * 分页查询课题意见征集
 * @param {*} query
 */
export function getSubjectDutyDept (id) {
  return request({
    url: subjectUrls.getSubjectDutyDept+id,
    method: 'get',
  })
}

/**
 * 通过课题ID获取课题详细信息
 * @param {*} id
 * add by yxq
 */
export function getSubjectDetail (id) {
  return request({
    url: "/subject/" + id + "/detail",
    method: 'get',
  })
}

/**
 * 分页查询课题意见征集
 * @param {*} query
 */
export function getEndApplyDetail (id) {
  return request({
    url: subjectUrls.getEndApplyDetail+id,
    method: 'get',
  })
}

/**
 * 分页查询课题意见征集
 * @param {*} query
 */
export function getEndSubjectList (query) {
  return request({
    url: subjectUrls.getEndSubjectList,
    method: 'get',
    params:query,
  })
}

/**
 * 分页查询课题意见征集
 * @param {*} query
 */
export function getPlanList (query) {
  return request({
    url: subjectUrls.getPlanList,
    method: 'get',
    params:query,
  })
}


/**
 * 分页查询课题意见征集
 * @param {*} query
 */
export function getSubjectCollectionTreeList (query) {
  return request({
    url: '/opinion/target/subjectCollection',   //分页查询，意见征集目标（课题征集）
    method: 'get',
    params:query,
  })
}



/**
 * 导出结题申请信息
 * @param {*}
 * @param {*}
 */
export function exportToDoEndsubjectData (query) {
  return request({
    url: subjectUrls.exportToDoEndsubjectData,
    method: 'get',
    responseType: 'blob',
    params: query
  })
}

/**
 * 导出结题申请信息excel
 * @param {*}
 * @param {*}
 */
export function exportToDoEndsubjectDataExcel (query) {
  return request({
    url: subjectUrls.exportToDoEndsubjectDataExcel,
    method: 'get',
    responseType: 'blob',
    params: query
  })
}

/**
 * 导出课题计划页面excel
 * @param {*}
 * @param {*}
 */
export function exportSubjectExcel (query) {
  return request({
    url: subjectUrls.exportSubjectExcel,
    method: 'get',
    responseType: 'blob',
    params: query
  })
}
